/*
 * Copyright 2017 JessYan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.cj.mobile.iabp.mvp.ui.holder;

import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.cj.mobile.iabp.R;
import com.cj.mobile.iabp.app.utils.EventBusTags;
import com.cj.mobile.iabp.mvp.model.entity.MainEvent;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.integration.EventBusManager;

import butterknife.BindView;

/**
 * ================================================
 * 拍照片
 * ================================================
 */
public class CameraItemHolder extends BaseHolder<String> implements View.OnClickListener {
    @BindView(R.id.lila_evaluationactivity_camera)
    LinearLayout mLayout;

    // 类型
    private int type = 0;
    // 是否使用默认背景(默认是灰色，非默认是白色)
    private boolean isDefaultBg;

    public CameraItemHolder(View itemView) {
        super(itemView);
    }

    public void initData(int type, boolean isDefaultBg) {
        this.type = type;
        this.isDefaultBg = isDefaultBg;
    }

    @Override
    public void setData(@NonNull String info, int position) {
//        if (!isDefaultBg) {
//            mLayout.setBackgroundResource(R.drawable.dialog_white_bg);
//        }

        mLayout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.lila_evaluationactivity_camera) {
            EventBusManager.getInstance().post(new MainEvent(EventBusTags.UPLOAD_IMAGE_TAG, getPosition(), type), EventBusTags.HOME_TAG);
        }
    }

    @Override
    protected void onRelease() {
        this.mLayout = null;
    }
}
